package com.example.hearthstoneagain;

import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.os.Build;

public class NewsActivity extends ActionBarActivity {

	private Context context;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_news);

		context = this.getApplicationContext();
		
		Bundle extras = getIntent().getExtras();
		
		String news = extras.getString("titulo");
		
		BancodeDados banco = new BancodeDados(context);
		
		SQLiteDatabase dtb = banco.getReadableDatabase();
		
		String args[] = {news};
		
		String nomecol[] = {"texto"};
		
		Cursor resp_news = dtb.query("news", nomecol, "titulo = ?", args, null, null, null);
		
		resp_news.moveToFirst();
		
		TextView txv = (TextView) this.findViewById(R.id.textView1);
		
		TextView txv2 = (TextView) this.findViewById(R.id.textView2);
		
		txv.setText(news);
		
		txv2.setText(resp_news.getString(0));
		
	}

}
